<?php

global 	$tab_feature_b1,
        $tab_feature_b2,
        $tab_count_b1,
        $tab_count_b2,
				$tab_b1_titles,
				$tab_b2_titles,
				$panel_1_active_tab_id,
				$panel_2_active_tab_id;


if ( $_SERVER['QUERY_STRING'] != '')
{
	$gn_pos = strripos( $_SERVER['QUERY_STRING'], 'tab_id=');
	
	if ( $gn_pos === false )
	{
	  //
	}
	else
	{
	  $gn_tab_id = substr( $_SERVER['QUERY_STRING'], $gn_pos + 7);

		if ( substr($gn_tab_id, 0, 1) == '1' )
		{
			$panel_1_active_tab_id = substr( $gn_tab_id, 2);
		}
		else
		{
			$panel_2_active_tab_id = substr( $gn_tab_id, 2);
		}
	}
}

$active_tab_id = $panel_1_active_tab_id;

function  print_tab_panel_1( $active_tab_id = '1' )
{
	global 	$tab_feature_b1,
	        $tab_feature_b2,
	        $tab_count_b1,
	        $tab_count_b2,
					$tab_b1_titles,
					$tab_b2_titles,
					$panel_1_active_tab_id,
					$panel_2_active_tab_id;



	if ( $active_tab_id == '' )
	{
	  $active_tab_id = 1;
	}
	
  $panel_1_active_tab_id = $active_tab_id;
  
	$output_line = '';
	
	$output_line = '<div id="tab_panel_container">
	                	<div id="tab_panel_tabs_container">';

	_e( $output_line, 'german_newspaper');

  get_tab_b1_titles();

	$output_line = '';

	if ( $_SERVER['QUERY_STRING'] == '' )
		$uri_script = 'index.php';
	else
	  $uri_script = '';

	$gn_strpos 			= strpos( $_SERVER['REQUEST_URI'], '?tab_id=');
	if ( $gn_strpos === false )
	{
		$gn_request_uri = $_SERVER['REQUEST_URI'];
	}
	else
	{
		$gn_strlen 			= strlen( $_SERVER['REQUEST_URI'] );
		$gn_request_uri = substr( $_SERVER['REQUEST_URI'], 0, ($gn_strpos ));
	}

	//  print tabs
	foreach ( $tab_b1_titles as $index => $title )
	{
	  if ( $index == $active_tab_id )
	  {
			$class = ' class="tab_active" ';
	  }
	  else
	  {
	    $class = ' class="tab_inactive" ';
		}

	  $output_line	= '<div id="tab_panel_tab"' . $class . '>';
	  $output_line .= '<a href="'. $gn_request_uri . $uri_script . '?tab_id=1_' . $index . '">' . $title . '</a>';
	  $output_line .= '</div>';
	  
		_e( $output_line, 'german_newspaper');
	}
	                	
	$output_line = ' 	</div>
	                	<div id="tab_panel_body">';

	_e( $output_line, 'german_newspaper');

  $name = 'Tab-Panel-1_Tab-' . $active_tab_id;

							echo '<ul>';
							/* Widgetized sidebar, if you have the plugin installed. */
							if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar( $name ) )
							{
 	    					echo '<ul> </ul>';
							}
							echo '</ul>';

	$output_line = ' 	</div>
	               </div>';
					
	_e( $output_line, 'german_newspaper');
	
	return;
}



$active_tab_id = $panel_2_active_tab_id;

function  print_tab_panel_2( $active_tab_id = '1' )
{
	global 	$tab_feature_b1,
	        $tab_feature_b2,
	        $tab_count_b1,
	        $tab_count_b2,
					$tab_b1_titles,
					$tab_b2_titles,
					$panel_1_active_tab_id,
					$panel_2_active_tab_id;

	if ( $active_tab_id == '' )
	{
	  $active_tab_id = 1;
	}

  $panel_2_active_tab_id = $active_tab_id;

	$output_line = '';

	$output_line = '<div id="tab_panel_container">
	                	<div id="tab_panel_tabs_container">';

	_e( $output_line, 'german_newspaper');

  get_tab_b2_titles();

	$output_line = '';

	if ( $_SERVER['QUERY_STRING'] == '' )
		$uri_script = 'index.php';
	else
	  $uri_script = '';

	$gn_strpos 			= strpos( $_SERVER['REQUEST_URI'], '?tab_id=');
	if ( $gn_strpos === false )
	{
		$gn_request_uri = $_SERVER['REQUEST_URI'];
	}
	else
	{
		$gn_strlen 			= strlen( $_SERVER['REQUEST_URI'] );
		$gn_request_uri = substr( $_SERVER['REQUEST_URI'], 0, ($gn_strpos ));
	}

	//  print tabs
	foreach ( $tab_b2_titles as $index => $title )
	{
	  if ( $index == $active_tab_id )
	  {
			$class = ' class="tab_active" ';
	  }
	  else
	  {
	    $class = ' class="tab_inactive" ';
		}

	  $output_line	= '<div id="tab_panel_tab"' . $class . '>';
	  $output_line .= '<a href="'. $gn_request_uri . $uri_script . '?tab_id=2_' . $index . '">' . $title . '</a>';
	  $output_line .= '</div>';

		_e( $output_line, 'german_newspaper');
	}

	$output_line = ' 	</div>
	                	<div id="tab_panel_body">';

	_e( $output_line, 'german_newspaper');

	if ( $tab_feature_b1 == 'on' )
	{
	  $sidebar_index = 2 + $tab_count_b1 + $active_tab_id;
	}
	else
	{
	  $sidebar_index = 3 + $active_tab_id;
	}

  $name = 'Tab-Panel-2_Tab-' . $active_tab_id;

							echo '<ul>';
							/* Widgetized sidebar, if you have the plugin installed. */
							if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar( $name ) )
							{
 	    					echo '<ul> </ul>';
							}
							echo '</ul>';

	$output_line = ' 	</div>
	               </div>';

	_e( $output_line, 'german_newspaper');

	return;
}

?>